<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="icon" href="./favicon.ico" type="image/x-icon"/>
    <title>litemall-vue</title>
</head>

<body>
<noscript>
    <strong>Please enable it to continue.</strong>
</noscript>
<div id="app">
    <div class="lds-ball">
        <div></div>
    </div>
</div>
<!-- built files will be auto injected -->
</body>

<script type="text/javascript">
    mui.init({
        keyEventBind: {
            backbutton: true, //关闭back按键监听
        }
    })
    //首页返回键处理
    // 处理逻辑： 1s内，连续两次按返回键，则退出应用；
    var first = null;
    mui.back = function () {
        // 首次按键， 提示 再按一次退出应用
        if (!first) {
            first = new Date().getTime();//记录第一次按下回退键的时间
            var route_name = window.location.hash;
            if (route_name.search('mine') != -1 || route_name.search('login') != -1) {
                mui.toast("再按一次退出应用");
                setTimeout(function () {
                    //1s 后清除
                    first = null;
                }, 500);
            } else {
                history.go(-1); // 回退到上一页
                first = null;
            }
        } else {
            if (new Date().getTime() - first < 500) {
                //如果两次按下的时间小于1s
                plus.runtime.quit(); //那么就退出app
            }
        }
    }
</script>


</html>